home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 November / macformat-018.iso / Utility Spectacular / Developer / SAT / Collision][ ƒ / Collision][.p < prev    next >
Encoding:
Text File  |  1994-07-26  |  1.3 KB  |  52 lines  |  [TEXT/PJMM]

  1. {******************************}
  2. {********* SAT Collision ][ **********}
  3. {******************************}
  4.  
  5. {A more advanced version of SAT Collision, demonstrating the use of callback routines}
  6. {(hit task) for collision handling. What has happened is that the apples switch between}
  7. {good and bad, and we are not supposed to eat it when it's bad.}
  8.  
  9. program SATcollisionII;
  10.  
  11.     uses
  12.         SAT, sMrEgghead, sApple;
  13.  
  14.     var
  15.         ignoreSp: SpritePtr;
  16.         l: longint;
  17.         ignore: integer;
  18.         p: Point;
  19. begin
  20. {Standard Inits are done by Think Pascal.}
  21.  
  22.     ConfigureSAT(true, kVPositionSort, kBackwardCollision, 32);
  23.     InitSAT(128, 129, 512, 322);
  24.  
  25.     InitMrEgghead;
  26.     InitApple;
  27.  
  28.     ShowWindow(gSAT.wind);
  29.     SelectWindow(gSAT.wind);
  30.     PeekOffscreen;
  31.  
  32.     GetMouse(p);
  33.     ignoreSp := NewSprite(0, p.h, p.v, @SetupMrEgghead);
  34.     ignoreSp := NewSprite(0, 0, Rand(gSAT.offSizeV - 32), @SetupApple);
  35.  
  36.     HideCursor;
  37.  
  38. {Get two channels if possible, since we use fairy long sounds.}
  39.     ignore := SATSoundInitChannels(2);
  40.  
  41.     repeat
  42.         l := TickCount;
  43.         RunSAT(true);
  44. {Start a new sprite once in a while.}
  45.         if Rand(40) = 1 then
  46.             ignoreSp := NewSprite(0, 0, Rand(gSAT.offSizeV - 32), @SetupApple);
  47.         while l > TickCount - 2 do {Maximize speed to 30 fps}
  48.             ;
  49.     until Button;
  50.     ShowCursor;
  51.     SATSoundShutUp; {Always make sure the sound channel is de-allocated!}
  52. end.